package app 
{
	import app.modules.TreeFolderInfo;
	import app.textures.TextureInfo;
	import app.textures.TextureInfoGroupe;
	import drawing.FurniturePaletteProvider;
	import events.AppModelEvents;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.utils.Dictionary;
	import furnitures.FurnitureModel;
	/**
	 * ...
	 * @author Dmitriy Gaiduk
	 */
	
	 /**
	 * When state changed
	 * @eventType flash.events.Event
	 */
	[Event(name = "change", type = "flash.events.Event")]
	
	/* When facade texture changed
	 * @eventType events.AppModelEvents
	 */
	[Event(name = "FACADE_TEXTURE_CHANGE", type = "events.AppModelEvents")]
	
	
	/* When tabletop texture changed
	 * @eventType events.AppModelEvents
	 */
	[Event(name = "TABLETOP_TEXTURE_CHANGE", type = "events.AppModelEvents")]
	
	/* 
	 * @eventType events.AppModelEvents
	 */
	[Event(name = "FURNITURE_TYPE_CHANGE", type = "events.AppModelEvents")]
	
	/* room size changed
	 * @eventType events.AppModelEvents
	 */
	[Event(name = "ROOM_SIZE_CHANGE", type = "events.AppModelEvents")]
	public class AppModel extends EventDispatcher
	{
		
		public var tabletopTextures:Vector.<TextureInfoGroupe>;
		public var facadeTextures:Vector.<TextureInfoGroupe>;
		
		private var _inited:Boolean;
		
		private var _roomWidth:Number;
		private var _roomHeight:Number;
		private var _roomLength:Number;
		
		public var bottomFurnitures:Vector.<TreeFolderInfo>;
		public var topFurnitures:Vector.<TreeFolderInfo>;
		public var techFurnitures:Vector.<TreeFolderInfo>;
		public var furnituresDict:Dictionary;
		
		
		public var techTextureGroupe:TextureInfoGroupe;
		
		//private var _currentFacadeTexture:TextureInfo = null;
		//private var _currentTabletopTexture:TextureInfo = null;
		private var _furnitureForAdd:FurnitureModel = null;
		
		/**
		 * Use for draw doors, tabletop furniture
		 */
		public var paletteProvider:FurniturePaletteProvider;
		
		public var galleryURL:String = "";
		public var tutorVideoUrl:String = "";
		public var addFavoritesFunc:String = "";
		
		
		// butons
		/*public var btnRoomSize_Title:String = "";
		public var btnBottomFurn_Title:String = "";
		public var btnTopFurn_Title:String = "";
		public var btnAppliances_Title:String = "";
		public var btnFacadeTexture_Title:String = "";
		public var btnTabletopTexture_Title:String = "";*/
		
		
		public function AppModel() 
		{
			_inited = false;
			
		}
		
		public function get inited():Boolean 
		{
			return _inited;
		}
		
		public function set inited(value:Boolean):void 
		{
			if (_inited != value)
			{
				_inited = value;
				dispatchEvent(new Event(Event.CHANGE));
			}
		}
		
		public function get roomWidth():Number 
		{
			return _roomWidth;
		}
		
		
		public function set roomWidth(value:Number):void 
		{
			if (_roomWidth != value)
			{
				_roomWidth = value;
				dispatchEvent(new AppModelEvents(AppModelEvents.ROOM_SIZE_CHANGE));
			}
		}
		
		public function get roomHeight():Number 
		{
			return _roomHeight;
		}
		
		public function set roomHeight(value:Number):void 
		{
			if (_roomHeight != value)
			{
				_roomHeight = value;
				dispatchEvent(new AppModelEvents(AppModelEvents.ROOM_SIZE_CHANGE));
			}
		}
		
		public function get roomLength():Number 
		{
			return _roomLength;
		}
		
		public function set roomLength(value:Number):void 
		{
			if (_roomLength != value)
			{
				_roomLength = value;
				dispatchEvent(new AppModelEvents(AppModelEvents.ROOM_SIZE_CHANGE));
			}
		}
		
		/*public function get currentFacadeTexture():TextureInfo
		{
			return _currentFacadeTexture;
		}
		
		public function set currentFacadeTexture(value:TextureInfo):void 
		{
			if (_currentFacadeTexture != value)
			{
				_currentFacadeTexture = value;
				dispatchEvent(new AppModelEvents(AppModelEvents.FACADE_TEXTURE_CHANGE));
			}
		}
		
		public function get currentTabletopTexture():TextureInfo 
		{
			return _currentTabletopTexture;
		}
		
		public function set currentTabletopTexture(value:TextureInfo):void 
		{
			if (_currentTabletopTexture != value)
			{
				_currentTabletopTexture = value;
				dispatchEvent(new AppModelEvents(AppModelEvents.TABLETOP_TEXTURE_CHANGE));
			}
		}
		*/
		public function get furnitureForAdd():FurnitureModel 
		{
			return _furnitureForAdd;
		}
		
		public function set furnitureForAdd(value:FurnitureModel):void 
		{
			if (_furnitureForAdd != value)
			{
				_furnitureForAdd = value;
				dispatchEvent(new AppModelEvents(AppModelEvents.FURNITURE_TYPE_CHANGE));
			}
		}
		
		
		
	}

}